package com.example.administrator.orchardeveryday.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;


import com.example.administrator.orchardeveryday.R;
import com.example.administrator.orchardeveryday.bean.HomeEntity;
import com.example.administrator.orchardeveryday.utils.ImageLoaderHelper;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by Administrator on 15-10-21.
 */
public class HomeFragmentListAdapter extends AppBaseAdapter<HomeEntity.BannerEntity>{
    DisplayImageOptions displayImage;
    public HomeFragmentListAdapter(List list, Context context) {
        super(list, context);
        displayImage = ImageLoaderHelper.getDisplayImageLoader();
    }

    @Override
    public ViewHolder getViewHolder(int position, View convertView, ViewGroup parent) {
        HomeEntity.BannerEntity banner=list.get(position);
        ViewHolder vh=ViewHolder.get(context,convertView,parent, R.layout.item_home_fragment_listview);
        ImageView iv= (ImageView) vh.findViewById(R.id.home_fragment_list_iv);
        iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
        ImageLoader.getInstance().displayImage(banner.getPhoto(), iv, displayImage);
        return vh;
    }
}
